package cn.iocoder.yudao.module.ao.dal.mysql.student;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ao.dal.dataobject.student.StudentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ao.controller.admin.student.vo.*;

/**
 * 学生信息 Mapper
 *
 * @author 智教云枢
 */
@Mapper
public interface StudentMapper extends BaseMapperX<StudentDO> {

    default PageResult<StudentDO> selectPage(StudentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StudentDO>()
                .eqIfPresent(StudentDO::getStudentNo, reqVO.getStudentNo())
                .likeIfPresent(StudentDO::getName, reqVO.getName())
                .eqIfPresent(StudentDO::getGender, reqVO.getGender())
                .eqIfPresent(StudentDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(StudentDO::getPhone, reqVO.getPhone())
                .eqIfPresent(StudentDO::getEmail, reqVO.getEmail())
                .eqIfPresent(StudentDO::getClassId, reqVO.getClassId())
                .eqIfPresent(StudentDO::getMajorId, reqVO.getMajorId())
                .betweenIfPresent(StudentDO::getEnrollmentDate, reqVO.getEnrollmentDate())
                .eqIfPresent(StudentDO::getEnrollmentTermId, reqVO.getEnrollmentTermId())
                .betweenIfPresent(StudentDO::getGraduationDate, reqVO.getGraduationDate())
                .eqIfPresent(StudentDO::getCurrentSemester, reqVO.getCurrentSemester())
                .eqIfPresent(StudentDO::getTotalCredits, reqVO.getTotalCredits())
                .eqIfPresent(StudentDO::getGpa, reqVO.getGpa())
                .likeIfPresent(StudentDO::getGuardianName, reqVO.getGuardianName())
                .eqIfPresent(StudentDO::getGuardianPhone, reqVO.getGuardianPhone())
                .eqIfPresent(StudentDO::getAddress, reqVO.getAddress())
                .eqIfPresent(StudentDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StudentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StudentDO::getStudentId));
    }

    default StudentDO selectByStudentNo(String studentNo) {
        return selectOne(new LambdaQueryWrapperX<StudentDO>()
                .eq(StudentDO::getStudentNo, studentNo));
    }

}